package com.some;

import java.util.Scanner;

public class BaiDu_12_2 {
    int res = Integer.MAX_VALUE;
    boolean[] flag;
    public int littlePrice(int[][] num){
        int m = num.length;
        if (m<1){
            return 0;
        }
        flag = new boolean[m];
        dfs(num,0,0);
        return res;
    }
    public void dfs(int[][] num,int day,int sum){
        if (day== num.length){
            res = Math.min(sum,res);
            return;
        }
        for (int i = 0; i < num.length; i++) {
            if (flag[i]){
                continue;
            }
            if (day%2!=1){
                sum+=num[i][0]+day*num[i][1];
            }
            flag[i] = true;
            dfs(num,day+1,sum);
            //回溯
            flag[i] = false;
            if (day%2!=1){
                sum-=num[i][0]+day*num[i][1];
            }
        }
        return;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //商品数量
        int count = sc.nextInt();
        //存储商品的数组
        int[][] num = new int[count][2];
        for (int i = 0; i < count; i++) {
            for (int j = 0; j < 2; j++) {
                num[i][j] = sc.nextInt();
            }
        }
        BaiDu_12_2 obj = new BaiDu_12_2();
        int[][] num1 = {{6,8},{2,9},{4,7}};
        System.out.println(obj.littlePrice(num1));
    }
}
